<script type="text/javascript" src="<?= base_url() ?>resource/js/layer/layer.js"></script>
<!--top结束-->
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left'); ?>
            <!--left end-->

            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?= $this->breadcrumb->generateHTML(); ?> </div>
                <!--breadcrumb end-->

                <!-- contents start -->
                <div id="contents">
                    <div id="ct_search">
                        <form action="<?= blang_url('wms/ReceivingOrderList/show_list') ?>"  >
                            <table id="search_tb">
                                <tr>
                                    <td>
                                        SKU： <input type="text" name="sku" size="30" placeholder="sku">
                                        &nbsp;&nbsp;&nbsp;<?= lang('wms_ckh') ?>： <input type="text" name="refNum" size="30" placeholder="<?= lang('wms_ckh') ?> ">&nbsp;&nbsp;&nbsp;
                                        <input type="submit" value=" <?= lang('wms_ss') ?>  ">
                                        <input type="button" onclick="selectedSubmit()" style="margin-left: 300px;" value="<?= lang('wms_plqrdh') ?>">
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div class="ct_content">
                        <table class="tbwd800">
                            <tr>
                                <th><input type='checkbox' id='checkall' name='checkall' /></th>
                                <th><?= lang('wms_rkdh') ?></th>
                                <th><?= lang('wms_tp') ?></th>
                                <th><?= lang('wms_cplx') ?></th>
                                <th><?= lang('wms_cppp') ?></th>
                                <th>SKU</th>
                                <th><?= lang('wms_mc') ?></th>
                                <th><?= lang('wms_sl') ?></th>
                                <th><?= lang('wms_ckh') ?></th>
                                <th><?= lang('wms_rklx') ?></th>
                                <th><?= lang('wms_ckdm') ?></th>
<!--                                <th><?= lang('wms_ckcw') ?></th>-->
                                <th><?= lang('wms_czlc') ?></th>
                            </tr>
                            <?php
                            $urlParam = @http_build_query($this->input->get());
                            foreach ($receivingList as $row)
                            {
                                ?>
                                <tr align="left" class="moves">
                                    <?php if (0 == $row['status'])
                                    { ?>
                                        <td><input type='checkbox' id='checkbox<?= $row['id'] ?>' name='checkid' value='<?= $row['id'] ?>' /></td>
                                        <?php
                                    }
                                    else
                                    {
                                        ?>
                                        <td></td><?php } ?>
                                    <td><?= $row['order_id'] ?></td>
                                    <td><?= $row[''] ?></td>
                                    <td><?= $row['product_type_id']; ?></td>
                                    <td><?= $row['product_brand_id'] ?></td>
                                    <td><?= $row['sku'] ?></td>
                                    <td><?= $row['products_name_cn'] ?></td>
                                    <td><?= $row['quantity'] ?></td>  
                                    <td><?= $row['ref_num'] ?></td>
                                    <td><?= $row['order_from'] ?></td>
                                    <td><?='('.$row['whs_code'].')'.$row['whs_name']?></td>
<!--                                    <td><?php if ('' == $row['grid_id']): ?>
                                            <select class="grid_select" id="<?= ($row['id'] . '_' . $row['whs_code'] . '_' . $row['sku']) ?>" >
                                                <option value =""></option>  
                                                <?php foreach ($grid_data[$row['whs_code']] as $key => $grid_list)
                                                { ?>
                                                    <option value ="<?= $grid_list['grid_id'] ?>"><?= $grid_list['grid_id'] ?></option>  
                                                <?php } ?>
                                            </select>
                                        <?php else: ?><?= $row['grid_id'] ?><?php endif; ?></td>-->
                                    <?php if (0 == $row['status'])
                                    { ?>
                                        <td><a href="<?= blang_url('wms/ReceivingOrderList/store_in/' . $row['id'] . '?' . $urlParam) ?>" onclick="return confirm('<?=  lang('wms_tips_tsqrrk'); ?>')"><?= lang('wms_panel_30032') ?></a></td>
                                        <?php
                                    }
                                    else
                                    {
                                        ?>
                                        <td><?= (1 == $row['status']) ? 'Complete' : '' ?></td>
                                    <?php } ?>
                                </tr>
                            <?php } ?>
                            <tr align="center">
                                <td colspan="14"><?= $pageShow ?></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $("#checkall").click(
    function(){
        if(this.checked){
            $("input[name='checkid']").prop('checked', true)
        }else{
            $("input[name='checkid']").prop('checked', false)
        }
    } 
);
    function selectedSubmit(){  
        var r=confirm("<?= lang('wms_tips_tsqrrk'); ?>");
        var ids=new Array()
        if(r){
            $("input[name='checkid']:checkbox:checked").each(function(){
                ids.push($(this).val());
            });
        }
        if(ids.length<1){
            alert('<?= lang('wms_tips_xzjl'); ?>');
            return false ;
        }
        //        var idsjson=JSON.stringify(ids);
        var idsStr =ids.join();
        window.location.href=('<?= blang_url("wms/ReceivingOrderList/store_in_batch") ?>?ids='+idsStr+'&<?= $urlParam ?>');
        
    }
    function select_grid(sku,grid_id,whs_code){
        
        var request_url=window.location.href;
        $.ajax({
            type:'post',
            timeout:60000,
            data:{sku:sku,grid_id:grid_id,whs_code:whs_code,request_url:request_url},
            url:"<?= blang_url('wms/ReceivingOrderList/select_grid') ?>",
            beforeSend:function(XMLHttpRequest){
                LDindex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            }, 
            success: function (msg) {
                layer.close(LDindex);  
                obj=JSON.parse(msg);
                location.reload();
            },
            error: function (e, jqxhr, settings, exception) {
              
                layer.close(LDindex); 
            },
            complete : function(XMLHttpRequest,status){
                layer.close(LDindex); 
                if(status=='timeout'){
                    alert("<?=lang('wms_tips_timeout')?>");
                }
            }
        });
    };
    $(".grid_select").each(function(){
        console.log(this);
        $("#"+this.id).change(function() {
            var ids=this.id;
            var grid_id=this.value;
            window.location.href=('<?= blang_url("wms/ReceivingOrderList/select_grid") ?>?ids='+ids+'&grid_id='+grid_id+'&url='+window.location.href);
        }); 
    });
</script>
